package com.cooper.moviedb.bo;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**
 * Created with IntelliJ IDEA.
 * User: cooperlee
 * Date: 11/19/12
 * Time: 12:29 PM
 */
@javax.persistence.Table(name = "MEDIA_INFO", schema = "", catalog = "media_service_db")
@Entity
public class MediaInfoEntity {

    public MediaInfoEntity(){

    }

    public MediaInfoEntity(MediaEntity mediaEntity,String keyName, String value) {
        this.mediaEntity = mediaEntity;
        this.keyName = keyName;
        this.value = value;
    }

    private String id;

    @Id
    @GenericGenerator(name="idGenerator",strategy = "uuid")
    @GeneratedValue(generator = "idGenerator")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    private MediaEntity mediaEntity;

    @ManyToOne()
    @JoinColumn(name = "MEDIA_ID", referencedColumnName = "id")
    public MediaEntity getMediaEntity() {
        return mediaEntity;
    }

    public void setMediaEntity(MediaEntity mediaEntity) {
        this.mediaEntity = mediaEntity;
    }

    private String keyName;

    @javax.persistence.Column(name = "KEY_NAME", nullable = false, insertable = true, updatable = true, length = 50, precision = 0)
    @Basic
    public String getKeyName() {
        return keyName;
    }

    public void setKeyName(String keyName) {
        this.keyName = keyName;
    }

    private String value;

    @javax.persistence.Column(name = "VALUE", nullable = true, insertable = true, updatable = true, length = 90000, precision = 0)
    @Basic
    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        MediaInfoEntity that = (MediaInfoEntity) o;

        if (keyName != null ? !keyName.equals(that.keyName) : that.keyName != null) return false;
        if (value != null ? !value.equals(that.value) : that.value != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = 0;
        result = 31 * result + (keyName != null ? keyName.hashCode() : 0);
        result = 31 * result + (value != null ? value.hashCode() : 0);
        return result;
    }
}
